<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>产品信息表</title>
<meta name="decorator" content="default" />
<script type="text/javascript">
	$(document).ready(
			function() {
				$("#inputForm")
						.validate(
								{
									submitHandler : function(form) {
										loading('正在提交，请稍等...');
										form.submit();
									},
									errorContainer : "#messageBox",
									errorPlacement : function(error, element) {
										$("#messageBox").text("输入有误，请先更正。");
										if (element.is(":checkbox")
												|| element.is(":radio")
												|| element.parent().is(
														".input-append")) {
											error.appendTo(element.parent()
													.parent());
										} else {
											error.insertAfter(element);
										}
									}
								});
			});
	
	//备份数据库
	function submit_backup_db(){
		$("#inputForm").attr("action", "${ctx}/sys/appManage/backup");
		$("#inputForm").submit();
	}
	
	//执行更新脚本
	function submit_run_sql(){
		$("#inputForm").attr("action", "${ctx}/sys/appManage/runSql");
		$("#inputForm").submit();
	}
	
	//初始化模块
	function submit_run_init(){
		$("#inputForm").attr("action", "${ctx}/sys/appManage/initModules");
		$("#inputForm").submit();
	}
	
	//清除所有缓存
	function submit_clear_all(){
		$("#inputForm").attr("action", "${ctx}/sys/appManage/clearAllCache");
		$("#inputForm").submit();
	}
	
	//清除组织架构缓存
	function submit_clear_org(){
		$("#inputForm").attr("action", "${ctx}/sys/appManage/clearCacheByOrg");
		$("#inputForm").submit();
	}
	
	//清除菜单缓存
	function submit_clear_mune(){                           
		$("#inputForm").attr("action", "${ctx}/sys/appManage/clearCacheByMenu");
		$("#inputForm").submit();
	}
</script>
</head>
<body>
	<form id="inputForm" action="" method="post"
		class="form-horizontal btnbottom">
		<sys:message content="${message}" />
		<div style="padding-left: 20px; padding-top: 50px;">
		    <shiro:hasPermission name="false">
			  <button id="backup_db" type="button" class="btn-custom" style="padding-right: 10px"
				onclick="submit_backup_db();">备份数据库</button>
		    </shiro:hasPermission>
		    <shiro:hasPermission name="sys:appManage:runSql">
			  <button id="run_sql" type="button" class="btn-custom" onclick="submit_run_sql();">执行更新脚本</button>
		    </shiro:hasPermission>
			<button id="clear_all" type="button" class="btn-custom" onclick="submit_clear_all();">清除所有缓存</button>
			<button id="clear_org" type="button" class="btn-custom" onclick="submit_clear_org();">清除组织架构缓存</button>
			<button id="clear_mune" type="button" class="btn-custom" onclick="submit_clear_mune();">清除菜单缓存</button>
		</div>
		<div style="padding-left: 20px; padding-top: 10px;">
		     <select name="sqlPath" style="width: 250px">
		         <option value="">请选择初始化模块</option>
		         <option value="db/cms/cms.sql">信息服务</option>
		         <option value="db/ncp/ncp.sql">农产品</option>
		         <option value="db/put/put.sql">农业投入品(需要同时初始化自定义表单)</option>
		         <option value="db/equipment/equipment.sql">质量检测</option>
		         <option value="db/eform/eform.sql">自定义表单</option>
		     </select>
			<button id="run_init" type="button" class="btn-custom" onclick="submit_run_init();">初始化模块</button>
		</div>

	</form>
</body>
</html>